package DAL;
/**hofit**/
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

public class ItemCopies_DAL {
	
	private int itemID;
	
	private int itemCopyID;
	
	private Date printDate;
	
	private Date purchaseDate;
	
	private int status;

	/**
	 * 
	 * @param arrItemCopy
	 * Constructor
	 */
	public ItemCopies_DAL(ArrayList<String> arrItemCopy) {
		super();
		SimpleDateFormat myFormate=new SimpleDateFormat("yyyy-MM-dd");
		this.itemID = Integer.parseInt(arrItemCopy.get(0));
		this.itemCopyID = Integer.parseInt(arrItemCopy.get(1));
		try {
			this.printDate =(Date)myFormate.parse(arrItemCopy.get(2));
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(this.printDate);
		try {
			this.purchaseDate = (Date)myFormate.parse(arrItemCopy.get(3));
		} catch (ParseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.out.println(this.purchaseDate);
		this.status = Integer.parseInt(arrItemCopy.get(4));
	}
/**
 * 
 * @param value
 * set Item ID
 */
	private void setItemID(int value){
		this.itemID = value;
	}
	/**
	 * 
	 * @return get Item ID
	 */
	public int getItemID() {
		return itemID;
	}
	/**
	 * 
	 * @param value
	 * set item Copy ID
	 */
	public void setItemCopyID(int value) {
		this.itemCopyID = value;
	}
	/**
	 * 
	 * @return get item Copy ID
	 */
	public int getItemCopyID() {
		return itemCopyID;
	}
	/**
	 * 
	 * @param value
	 * set print Date
	 */
	public void setPrintDate(Date value) {
		this.printDate = value;
	}
	/**
	 * 
	 * @return get print Date
	 */
	public Date getPrintDate() {
		return printDate;
	}
	/**
	 * 
	 * @param value
	 * set purchase Date
	 */
	public void setPurchaseDate(Date value) {
		this.purchaseDate = value;
	}
	/**
	 * 
	 * @return get purchase Date
	 */
	public Date getPurchaseDate() {
		return purchaseDate;
	}
	/**
	 * 
	 * @param value
	 * set status
	 */
	public void setStatus(int value) {
		this.status = value;
	}
	/**
	 * 
	 * @return get status
	 */
	public int getStatus() {
		return status;		
	}
	/**
	 * 
	 * @param itemCopy
	 * @return ArrayList
	 * convert item copy to array
	 */
	public ArrayList<String> itemCopyToArray(ItemCopies_DAL itemCopy)
	{
		ArrayList<String> arrItemCopy = new ArrayList<String>();
		SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
		
		arrItemCopy.add(Integer.toString(itemCopy.itemID));
		arrItemCopy.add(Integer.toString(itemCopy.itemCopyID));
		arrItemCopy.add(formatter.format(itemCopy.printDate));
		arrItemCopy.add(formatter.format(itemCopy.purchaseDate));
		arrItemCopy.add(Integer.toString(itemCopy.status));
		
		return arrItemCopy;
	}
	

	

}
